<?
include_once($_SERVER['DOCUMENT_ROOT']."/lucy/config.php");
include_once(INC.'sess.php');
include_once(CLA."lucy_feelings.class.php");
include_once(CLA."speech.class.php");

$lucy_feeling = new Lucy_feelings();

$is_word = ($_SESSION['options']['think'] == 1) ? 1 : is_word($_SESSION['in']['word']);

if($is_word){
	//	USER FEELING
	$user_speech = new Speech();
	$user_speech->set_feeling($user_speech->get_feeling($_SESSION['in']['word']));
	
	if($_SESSION['options']['think'] == 1){echo 222;
		$user_speech->set_type($user_speech->think_type($_SESSION['in']['word'], 1));
	}else{
		$user_speech->set_type($user_speech->get_type($_SESSION['in']['word']));
	}
	//	LUCY EMOTIONAL RESPONSE
	$usr_sp = $user_speech->feeling;
	
	
	if($usr_sp == 1){
		$lucy_feeling->add_feeling(1);
	}elseif($usr_sp == 2){
		$lucy_feeling->add_feeling(2);
	}elseif($usr_sp == 3){
		$lucy_feeling->add_feeling(3);
	}elseif($usr_sp ==4){
		$lucy_feeling->change(1);
	}elseif($usr_sp == 5){
		$lucy_feeling->change(1);
	}
	
	//	LUCY RESPONSE
	$lucy_speech = new Speech();
	$lucy_speech->set_feeling($lucy_feeling->get());
	$lucy_speech->set_type($user_speech->type);
	
	$return = $lucy_speech->get_response_word();//	Ja 0, tad nezin vārdu.
	
	if($_SESSION['no_learning'] == 1){
		$return = (rand(0, 3) == 0) ? 0 : $return;
	}
	
	if($user_speech->type == "sajūta" AND $user_speech->feeling == $lucy_speech->feeling){
		$me_to = "es arī";
	}else{
		$me_to = (rand(0, 1) == 0) ? 0 : "es gan";
	}
	
	
	if($return){
		$_SESSION['print']['echo'] = $return;
		$mod_name = "print";
		$send = "<meta http-equiv='refresh' content=\"0;url=http://localhost/lucy/sys/mod/".$mod_name.".php?inSess=".session_id()."\">";
		echo $send;
	}else{
		$_SESSION['help']['type'] = $lucy_speech->type;
		$_SESSION['help']['feeling'] = $lucy_speech->feeling;
		$_SESSION['help']['response_to'] = $_SESSION['in']['word'];
		
		$mod_name = "help_response";
		$send = "<meta http-equiv='refresh' content=\"0;url=http://localhost/lucy/sys/mod/".$mod_name.".php?inSess=".session_id()."\">";
		echo $send;
	}
	
}
?>